<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/wechat/js/copy/ZeroClipboard.js"></script>
<SCRIPT type="text/javascript">
    <!--
	var gridSetting = {
			id:'QhAdverAccountGrid',
			po:"QhAdverAccount",
			title:'',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"QhAdverAccountTb",
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "id desc"
			},
            oper:{
                isDisplay:'${sessionScope.userInfo.type}'=="B"?false:true,
                operName:"",
                url:"",
                cssClass:"Operation",
                width:80
            },
			fields:[
			   {	name:'id',
					hide:true
			   },{
                   name: 'uid',
                   descs:"广告主",
                   thstyle:"width:100px",
                   align:'center'
               },{
                   name: 'deposit',
                   descs:"金额",
                   thstyle:"width:100px",
                   align:'center'
               },
               {
                   name: 'note',
                   align:'left',
                   descs:"备注"
               },{
                   name: 'state',
                   align:'center',
                   descs:"状态",
                   thstyle:"width:60px"
               },{
                   name: 'createDateTime',
                   descs:"操作时间",
                   align:'center',
                   thstyle:"width:170px",
                   type:'datetime'
               },{
                   name: 'createUser',
                   descs:"操作人",
                   align:'center',
                   thstyle:"width:100px"
               }
			]
		};
	var grid;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];
		data.push({r:"=",name:'type',value:"充值"});
		if('${sessionScope.userInfo.type}'=="B"){
		   data.push({r:"=",name:'uid',value:"${sessionScope.userInfo.id}"});
		}
		grid.load({data:data});

		ajustHeight();

		$("#deleteBtn").click(function(){
        	grid.deletes("deleteMappedRoleNavis",function(ret){
                if(ret==-1){
                    layer.msg("删除失败，请重试！");
                }else{
                    layer.msg("删除" + ret.recordNum + "条记录！",function(ret){
                        grid.reload();
                    });
                }
            });
        });

    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="">列表</a>
  </li>
  <li>
    <a href="/qh/public/common/r2.htmls?page=account/recharge_edit">新增</a>
  </li>
</ul>
<div class="contrainer">
<div class="rcon2" style="padding-bottom:0;">
<table class="search_tb">
   <tr>
      <td>
         <input style="float:right" type="button" class="btnblue" value="删除" id="deleteBtn">
         <select name="state" style="width:100px;float:left;margin-left:25px;">
            <option value="">状态</option>
            <option value="99">未审核</option>
            <option value="1">已审核</option>
         </select>
         <div style="float:left;margin-left:30px;">
            <input type="text" onclick="WdatePicker()" name="createDateTime" placeholder="开始时间" />-<input type="text" onclick="WdatePicker()" name="createDateTime" placeholder="结束时间" />
         </div>
         <input type="button" class="searchbtn" value="" id="queryBtn">
      </td>
   </tr>
</table>
</div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>
</div>
<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $.ajaxSetup({
       async: false
    });
    $("#queryBtn").click(function(){
       var state = $(".ctable").find("select[name=state]").val();
       var createDateTime1 = $(".ctable").find(":input[name=createDateTime]:eq(0)").val();
       var createDateTime2 = $(".ctable").find(":input[name=createDateTime]:eq(1)").val();

       var data = [];
       data.push({r:"=",name:'type',value:"充值"});

       if(state!==""){
          data.push({r:"=",name:'state',value:state});
       }
       if(createDateTime1!==""){
          data.push({r:">=",name:'createDateTime',value:createDateTime1});
       }
       if(createDateTime2!==""){
          data.push({r:"<=",name:'createDateTime',value:createDateTime2});
       }

       grid.load({data:data});
       ajustHeight();
    });

    function afterLoad_QhAdverAccountTb(){
       $(".rcon2 .mtable tbody tr").each(function(){
          $state=$(this).find("td[name=state]");

          if($state.text()==99){
             $state.text('未审核');
             if('${sessionScope.userInfo.type}'=="A"){
                var html="<a href=javascript:audit("+$(this).attr("recordid")+",1,"+$(this).find("td[name=uid]").attr("value")+","+$(this).find("td[name=deposit]").text()+") style='margin-left:6px;' >审核</a>";
                $(this).find(".Operation").html(html);
             }
          }
          else{
             $state.text('已审核');
          }

          $createUser=$(this).find("td[name=createUser]");
          $.getJSON(g_path+"/public/common/getAdverName.htmls",{uid:$createUser.text()},function(data){
             $createUser.text(data.name);
          });

          $uid=$(this).find("td[name=uid]");
          $.getJSON(g_path+"/public/common/getAdverName.htmls",{uid:$uid.text()},function(data){
              $uid.text(data.name);
          });

       });
    }
    function audit(id,state,createUser,money){
       layer.confirm("真的要审核吗？",{btn:["确定","取消"]},function(index){
          layer.close(index);
          $.getJSON(g_path+"/public/common/rechargeStateEdit.htmls",{id:id,state:state},function(data){
             $.getJSON(g_path+"/public/common/editUserFund.htmls",{id:createUser,money:money},function(data){
                layer.alert("操作成功！");
                grid.reload();
             });
          });
       });
    }
</script>
</body>
</html>